<%@ Page Language="c#" AutoEventWireup="true" MasterPageFile="~/MasterPages/Main.Master" CodeFile="Role.aspx.cs" Inherits="_Role" Title="Role" %>

<asp:Content ID="Main" ContentPlaceHolderID="body" runat="server">
	<asp:Panel ID="roleDetail" Width="100%" runat="server">
		<fieldset>
			<legend>Role Detail</legend>
			<asp:GridView ID="roleGrid" AllowPaging="True" AllowSorting="True" BorderColor="White"
				BorderStyle="Ridge" CellSpacing="0" CellPadding="3" BackColor="#ffffff" AutoGenerateColumns="false"
				DataSourceID="roleSource" runat="server" Width="100%" EnableSortingAndPagingCallbacks="True">
				<HeaderStyle BackColor="#ffffff" HorizontalAlign="left" Font-Bold="true" />
				<AlternatingRowStyle BackColor="#CCCC99" />
				<PagerSettings Mode="NumericFirstLast" Position="Bottom" />
				<Columns>
					<asp:HyperLinkField HeaderText="ID" DataTextField="Id" SortExpression="Id" DataNavigateUrlFields="Id"
					DataNavigateUrlFormatString="~/SampleForms/Role.aspx?RoleId={0}" Target="_parent" />
					<asp:BoundField HeaderText="Name" DataField="Name" SortExpression="Name" />
					<asp:BoundField HeaderText="Description" DataField="Description" SortExpression="Description" />
				</Columns>
			</asp:GridView>		
		</fieldset>
	</asp:Panel>
    <asp:FormView ID="roleView" DataSourceID="roleDetailSource" DataKeyNames="Id"
	    OnModeChange="roleView_ModeChanged" Width="100%" runat="server">
        <ItemTemplate>
			 <fieldset>
				<legend>Role Detail</legend>
				<ol>
				<li>
				<asp:Label ID="idLabel" Text="Id" runat="server"/>
				<asp:Label ID="id" Text='<%# Eval("Id") %>' CssClass="formText" runat="server" />
				</li>
				<li>
				<asp:Label ID="nameLabel" Text='Name' runat="server"/>
				<asp:Label ID="name" Text='<%# Eval("Name") %>' Enabled="false" CssClass="formText" runat="server" />
				</li>
				<li>
				<asp:Label ID="descriptionLabel" Text='Description' runat="server"/>
				<asp:Label ID="description" Text='<%# Eval("Description") %>' Enabled="false" CssClass="formText" runat="server" />
				</li>
			    </ol>
			 </fieldset>
			 <asp:Button ID="add" CommandName="New" Text="Add" runat="server" />
			 <asp:Button ID="edit" CommandName="Edit" Text="Edit" runat="server" />
			 <asp:Button ID="delete" CommandName="Delete" Text="Delete" runat="server" />
		</ItemTemplate>
		<InsertItemTemplate>
			 <fieldset>
				<legend>New Role Detail</legend>
				<ol>
				<li>
				<asp:Label ID="nameLabel" Text='Name' runat="server"/><br/>
				<asp:TextBox id="name" Text='<%# Bind("Name") %>' Columns="50" CssClass="formText" runat="server" /><asp:RequiredFieldValidator ID="name_RequiredFieldValidator" ControlToValidate="name" Text="*" ErrorMessage="'Name' is required." SetFocusOnError="True" runat="server"/>
				</li>
				<li>
				<asp:Label ID="descriptionLabel" Text='Description' runat="server"/><br/>
				<asp:TextBox id="description" Text='<%# Bind("Description") %>' Columns="50" CssClass="formText" runat="server" />
				</li>
				<!-- TODO: Implement Many to Many (Logins) -->
				</ol>
			 </fieldset>
             <asp:Button ID="submit" CommandName="Insert" Text="Save" runat="server" />
        </InsertItemTemplate>
		<EditItemTemplate>
			<fieldset>
				<legend>Edit Role Detail</legend>
				<ol>
				<li>
				<asp:Label ID="idLabel" Text="Id" runat="server"/>
				<asp:Label Id="id" Text='<%# Bind("Id") %>' CssClass="formText" runat="server" />
				</li>
				<li>
				<asp:Label ID="nameLabel" Text='Name' runat="server"/><br/>
				<asp:TextBox id="name" Text='<%# Bind("Name") %>' Columns="50" CssClass="formText" runat="server" /><asp:RequiredFieldValidator ID="name_RequiredFieldValidator" ControlToValidate="name" Text="*" ErrorMessage="'Name' is required." SetFocusOnError="True" runat="server"/>
				</li>
				<li>
				<asp:Label ID="descriptionLabel" Text='Description' runat="server"/><br/>
				<asp:TextBox id="description" Text='<%# Bind("Description") %>' Columns="50" CssClass="formText" runat="server" />
				</li>
				<!-- TODO: Implement Many to Many (Logins) -->
				</ol>
			 </fieldset>
             <asp:Button ID="submit" CommandName="Update" Text="Save" runat="server" />
        </EditItemTemplate>
		<EmptyDataTemplate>
				<fieldset>
				<legend>Role Detail</legend>
				No Record Selected
				</fieldset>
			<asp:Button ID="add" CommandName="New" Text="Add" runat="server" />
		</EmptyDataTemplate>
    </asp:FormView>
	<asp:ObjectDataSource ID="roleSource" TypeName="Blog.Net.DataAccess.DataControls.RoleDataControl"
		DataObjectTypeName="Blog.Net.Business.BusinessObjects.RoleBO" SelectMethod="GetAll" SelectCountMethod="GetCountOfAll"
		InsertMethod="Save" UpdateMethod="Save" MaximumRowsParameterName="maxResults" StartRowIndexParameterName="firstResult"
		SortParameterName="sortExpression" EnablePaging="True" runat="server" >
		<InsertParameters>
            <asp:Parameter Name="role" Type="Object" />
            <asp:Parameter Direction="Output" Name="id" Type="Object" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="role" Type="Object" />
            <asp:Parameter Direction="Output" Name="id" Type="Object" />
        </UpdateParameters>
    </asp:ObjectDataSource>
    <asp:ObjectDataSource ID="roleDetailSource" SelectMethod="GetById" InsertMethod="Save" UpdateMethod="Save" DeleteMethod="Delete" DataObjectTypeName="Blog.Net.Business.BusinessObjects.RoleBO"
        TypeName="Blog.Net.DataAccess.DataControls.RoleDataControl" runat="server">
		<SelectParameters>
            <asp:QueryStringParameter Name="id" QueryStringField="RoleId" Type="Int32" />
        </SelectParameters>
		<InsertParameters>
            <asp:Parameter Name="role" Type="Object" />
            <asp:Parameter Direction="Output" Name="id" Type="Object" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="role" Type="Object" />
            <asp:Parameter Direction="Output" Name="id" Type="Object" />
        </UpdateParameters>
		<DeleteParameters>
            <asp:Parameter Name="role" Type="Object" />
        </DeleteParameters>
    </asp:ObjectDataSource>
	<asp:ObjectDataSource ID="loginSource" SelectMethod="GetAll" TypeName="Blog.Net.DataAccess.DataControls.LoginDataControl" runat="server"></asp:ObjectDataSource>
</asp:Content>